﻿using MediatR;
using W.Purchase.API.Application.Command;
using W.Purchase.Domain;
using W.Purchase.Repository.Interface;

namespace W.Purchase.API.Application.CommandHandler
{
    public class VendorFanCommandHandler : IRequestHandler<VendorFanCommand, List<Vendor>>
    {
        private readonly IVendorRepository vendorRepository;

        public VendorFanCommandHandler(IVendorRepository vendorRepository)
        {
            this.vendorRepository = vendorRepository;
        }

        public async Task<List<Vendor>> Handle(VendorFanCommand request, CancellationToken cancellationToken)
        {
            return await vendorRepository.GetAsync(w=>w.VendorId == request.VendorId);
        }
    }
}
